<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3><h:outputText style="font-weight: bold" value="Add new group buying item: "/></h3>
        <br/>

        <h:form>
            <p:panel style="background: #c2dfef;">
                <h:outputText value="In order to submit an effective group buying item, below are things to NOTICE: " style="font-family:verdana; font-size:small ; color: #004276; font-weight: bold"/> <br/>
                <h:outputText value="1. The effective period [start date, end date] must not be more than 7 days." style="font-family:verdana; font-size: small; color: #004276; "/><br/>
                <h:outputText value="2. The effective start date must be within one year as of today." style="font-family:verdana; font-size: small; color: #004276; "/><br/>
                <h:outputText value="3. The redemption period must start after the deal closes." style="font-family:verdana; font-size: small; color: #004276; "/><br/>
                <h:outputText value="4. Ending dates must be after starting dates. " style="font-family:verdana; font-size: small; color: #004276; "/><br/>
                <h:outputText value="5. All values except for 'vadidate requiremens' should not be empty. " style="font-family:verdana; font-size: small; color: #004276; "/><br/>
                <h:outputText value="6. If you wish to initiate an unlimited item, just put a very big number inside 'maximum quota'" style="font-family:verdana; font-size: small; color: #004276; "/><br/>
            </p:panel>
            <br/>

            <p:messages id="msg"/>
            <h:panelGrid columns="3" style="text-align: left">

                <h:outputLabel for="name" value="Item Name: "/>
                <p:inputText id="name" value="#{groupBuyingManagedBean.name}" required="true"
                             requiredMessage="dish name required!"/>
                <p:message for="name"/>

                <h:outputLabel for="originalPrice" value="Original Price: "/>
                <p:inputText id="originalPrice" value="#{groupBuyingManagedBean.originalPrice}" required="true"
                             requiredMessage="price value needed!">
                    <f:validateDoubleRange minimum="0"/>
                </p:inputText>
                <p:message for="originalPrice"/>


                <h:outputLabel for="offerPrice" value="Offering Price: "/>
                <p:inputText id="offerPrice" value="#{groupBuyingManagedBean.offeredPrice}" required="true"
                             requiredMessage="price value needed!">
                    <f:validateDoubleRange minimum="0"/>
                </p:inputText>
                <p:message for="offerPrice"/>

                <h:outputLabel for="effectiveStart" value="Effective Start Date: "/>
                <p:calendar id="effectiveStart" value="#{groupBuyingManagedBean.effectiveStart}"
                            pattern="dd MMM, yyyy (EEE)" mindate="#{groupBuyingManagedBean.today}"/>
                <p:message for="effectiveStart"/>


                <h:outputLabel for="effectiveEnd" value="Effective End Date: "/>
                <p:calendar id="effectiveEnd" value="#{groupBuyingManagedBean.effectiveEnd}"
                            pattern="dd MMM, yyyy (EEE)"/>
                <p:message for="effectiveEnd"/>

                <h:outputLabel for="redemptionStart" value="Redemption Start Date: "/>
                <p:calendar id="redemptionStart" value="#{groupBuyingManagedBean.redemptionStart}"
                            pattern="dd MMM, yyyy (EEE)" mindate="#{groupBuyingManagedBean.today}"/>
                <p:message for="redemptionStart"/>

                <h:outputLabel for="redemptionEnd" value="Redemption End Date: "/>
                <p:calendar id="redemptionEnd" value="#{groupBuyingManagedBean.redemptionEnd}"
                            pattern="dd MMM, yyyy (EEE)"/>
                <p:message for="redemptionEnd"/>

                <h:outputLabel for="minQuota" value="Minimum Quota: "/>
                <p:inputText id="minQuota" value="#{groupBuyingManagedBean.minQuota}" required="true"
                             requiredMessage="price value needed!">
                </p:inputText>
                <p:message for="minQuota"/>

                <h:outputLabel for="maxQuota" value="Maximum Quota: "/>
                <p:inputText id="maxQuota" value="#{groupBuyingManagedBean.maxQuota}" required="true"
                             requiredMessage="maximum quota value needed!">
                    <f:validateLongRange maximum="65535" minimum="0"/>
                </p:inputText>
                <p:message for="maxQuota"/>

                <h:outputLabel for="personalQuota" value="Maximum pieces can be bought by person: "/>
                <p:inputText id="personalQuota" value="#{groupBuyingManagedBean.personalQuota}" required="true"
                             requiredMessage="personal quota value needed!">
                </p:inputText>
                <p:message for="personalQuota"/>

                <h:outputLabel for="requireBooking" value="Require booking: "/>
                <h:selectOneRadio id="requireBooking" value="#{groupBuyingManagedBean.requireBookingStr}"
                                  required="true" requiredMessage="field cannot be empty">
                    <f:selectItem id="auto" itemLabel="yes" itemValue="true"/>
                    <f:selectItem id="manual" itemLabel="no" itemValue="false"/>
                </h:selectOneRadio>
                <p:message for="requireBooking"/>


                <h:outputLabel for="validateRequirements" value="Validate Requirements: "/>
                <p:inputTextarea id="validateRequirements" 
                                 value="#{groupBuyingManagedBean.validateRequirements}" 
                                 requiredMessage="price value needed!"
                                 style="width:400px; height:150px"/>
                <p:message for="validateRequirements"/>


                <h:outputLabel for="description" value="Description: "/> 
                <p:inputTextarea id="description" 
                                 value="#{groupBuyingManagedBean.description}" 
                                 required="true" requiredMessage="price value needed!"
                                 style="width:400px; height:150px"/>
                <p:message for="description"/>

                <p:commandButton id="newProposal" value="Submit new item proposal" ajax="false"
                                 actionListener="#{groupBuyingManagedBean.addNewProposal}"
                                 update="msg" />
                <p:ajaxStatus style="width:20px;height:20px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
            </h:panelGrid>


        </h:form>
    </ui:define>

</ui:composition>
